package model;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;

public class Bruger {
	
	private String name, gamertag, country, favGenre, email, filename;
	boolean ingame;
	private int password;
	private BufferedImage profilepic;
	private int width, height;
	
	
	public Bruger(String name, String gamertag, String country, String favGenre, String email){
		this.name = name;
		this.gamertag = gamertag;
		this.country = country;
		this.favGenre = favGenre;
		this.email = email;
		ingame = false;
		height = 100;
		width = 50;
		profilepic = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getGamertag() {
		return gamertag;
	}

	public void setGamertag(String gamertag) {
		this.gamertag = gamertag;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getFavGenre() {
		return favGenre;
	}

	public void setFavGenre(String favGenre) {
		this.favGenre = favGenre;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public boolean isIngame() {
		return ingame;
	}

	public void setIngame(boolean ingame) {
		this.ingame = ingame;
	}

	public int getPassword() {
		return password;
	}

	public void setPassword(int password) {
		this.password = password;
	}

	
	 /**
     * Create a picture by reading in a .png, .gif, or .jpg from
     * the given filename or URL name.
	 * @return 
     */
    public void Picture(String filename) {
        this.filename = filename;
        try {
            // try to read from file in working directory
            File file = new File(filename);
            if (file.isFile()) {
                profilepic = ImageIO.read(file);
            }

            // now try to read from file in same directory as this .class file
            else {
                URL url = getClass().getResource(filename);
                if (url == null) { url = new URL(filename); }
                profilepic = ImageIO.read(url);
            }
            width  = profilepic.getWidth(null);
            height = profilepic.getHeight(null);
        }
        catch (IOException e) {
            // e.printStackTrace();
            throw new RuntimeException("Could not open file: " + filename);
        }
    }
}

